﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Afvanding.RefToPumpService;

namespace Afvanding
{
    /// <summary>
    /// Interaction logic for AddPumpWindow.xaml
    /// </summary>
    public partial class AddPumpWindow : Window
    {
        private PumpServiceClient _pumpService;
        private int _stationId;

        public AddPumpWindow(int stationId)
        {
            InitializeComponent();

            _pumpService = new PumpServiceClient();
            _stationId = stationId;

            lblStationId.Content = _stationId.ToString();
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            double capacity;

            if (double.TryParse(txtCapacity.Text, out capacity))
            {
                int status = int.MinValue;
                if (cbStatus.Text == "Running")
                    status = 1;
                else if (cbStatus.Text == "Stopped")
                    status = 0;

                bool add = _pumpService.AddPump(capacity, status, _stationId);
                MessageBox.Show(add ? "tilføjet" : "ikke tilføjet");
            }
            else
                MessageBox.Show("Der skete en fejl");
        }
    }
}